from __future__ import with_statement

import sys, os
os.chdir('..')
sys.path.append('..')


import pyrind
from pyrind import RWindow
import testcase

class MyApplication():
	def __init__(self,w):
		w.title = 'Welcome'
		
		#use a grid, because can specify minimum size/width
		f = w.begin_frame()
		f.set_row_weight(0,minsize=300)
		f.set_col_weight(0,minsize=300)
		with w.add_frame(grid=(0,0), orient=pyrind.V):
			self.sld1 = w.add_slider((50,500),True, pad=(20,20))
			self.sld0 = w.add_slider((-4.0,10.0),False, resolution=0.1)
			print(self.sld0.range)
			print(self.sld1.range)
		
		w.end_frame()
		
	
		w.begin_frame()
		otestcase = testcase.TestCaseOpt(w)
		otestcase.addProperty(self.sld1, 'value', [10,100,200,300,300.4])
		otestcase.addProperty(self.sld1, 'range', [(50,500),(0,10),(-10,10)])
		otestcase.addProperty(self.sld1, 'height', [0, 20, 60, 100, 300 ])
		otestcase.addProperty(self.sld1, 'width', [0, 20, 60, 100, 300 ])
		
		otestcase.addProperty(self.sld1, 'onchanged', [None, self.handler1,self.handler2 ])
		
		otestcase.addRow()
		otestcase.addProperty(self.sld1, 'resolution', [1,0.1,0.05, 2, -1 ])
		#~ otestcase.addProperty(self.sld1, 'tickinterval', [1,0.1,0.05, 2, -1 ])
		otestcase.addProperty(self.sld1, 'enabled', [True, False ])
		otestcase.addProperty(self.sld1, 'label', [None,'','lbl1','lbl2'])
		otestcase.addProperty(self.sld1, 'showvalue', [True, False ])
		otestcase.addProperty(self.sld1, 'sliderlength', [0,1,10,20,30,60 ])
		
		otestcase.addRow()
		
		
		otestcase.addRow()
		otestcase.addProperty(self.sld1, 'color', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(self.sld1, 'bgcolor', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(self.sld1, 'font', [None, 'times','helvetica','courier', ('Lucida Console', 16, 'normal'),('Verdana', 6, 'normal') ])
		otestcase.addProperty(self.sld1, 'borderwidth', [0,1,2,3,4 ])
		otestcase.addProperty(self.sld1, 'borderstyle', ['sunken','raised','groove','ridge','flat'])
		
		
		
		
		
		w.end_frame()
		
		w.start()
		
	def handler1(self, value):
		print ('handler1', value)
		
	def handler2(self, value):
		print ('handler2', value)


app = MyApplication(RWindow())

